/*
 * Copyright (c) 2010, 2011
 *	Open Source Technologies Ltd.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the company nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COMPANY AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */
#ifndef __BLISS64_TOKEN_H__
#define __BLISS64_TOKEN_H__

#define TOKEN_MAGIC 0x13510000
#define TOKEN_DEAD  0x1351DEAD

#ifndef __TOKEN_T__
#define __TOKEN_T__
typedef struct token_st token_t;
#endif /* !__TOKEN_T__ */

enum token_type
{
	tt_integer,
	tt_float,
	tt_delimiter,
	tt_string,
	tt_keyword
};

struct token_st
{
	uint32_t  t_magic;
	char     *t_text;
	int       t_row;
	int       t_column;
	int       t_type;
};

#define is_token(obj)      is_object(obj, t_magic, TOKEN_MAGIC)
#define is_token_dead(obj) is_object_dead(obj, t_magic, TOKEN_MAGIC)
#define is_token_opt(obj)  is_object_opt(obj, t_magic, TOKEN_MAGIC)

__begin_decls

token_t *token_create     __p((const char *text));
token_t *token_initialize __p((token_t *token, const char *text));

void     token_finalize   __p((token_t *token));
token_t *token_destroy    __p((token_t *token));

__end_decls

#endif /* !__BLISS64_TOKEN_H__ */
